import utils.ComponentHandler;
/*
 * @ClassPath: C:\flashPage\flash_src\as\engine
 * @ClassPackage: engine
 * @ClassName: MyMenu.as
 * @Classdescription:This class handles is MAIN
 * @author vargaf
 * @Date: 20.08.2008
 * @Time:14:31:46
 * @Mod:
 * @eMail: francis.varga@juwimm.com
 *
 */
class engine.MyMenu {
	
	private static var currentY:Number							= 0;
	private static var spacer:Number							= 5;
	
	public function MyMenu(){
	}
	
	public static function createMenu(label:String, url:String):Void{
		
		var myMenuItem:MovieClip 	= ComponentHandler.getMenuIncluder().attachMovie("menuItems", "menuItems", ComponentHandler.getMenuIncluder().getNextHighestDepth());
		myMenuItem.labelTxtF.text	= label;
		myMenuItem._y				= currentY;
		
		currentY					= myMenuItem._height + myMenuItem._y + spacer;
				
		menuEvent(myMenuItem, url);	
		
	}
	
	private static function addLevel(label:String, url:String):Void{
		
		
		
	}
	
	private static function menuEvent(target:MovieClip, url:String):Void{
		
		var myListener:Object		= new Object();
		var myLoader:MovieClipLoader= new MovieClipLoader();
		var firstClick:Boolean		= true;
		myLoader.addListener(myListener);
		
		myListener.onLoadStart = function(target_mc:MovieClip) {
			
			trace("Template wird geladen: " + url);
		   
		};
				
		
		myListener.onLoadInit = function(target_mc:MovieClip):Void{
			
			trace("Template wurde geladen...");
			ComponentHandler.getContentIncluder()._visible = true;
			ComponentHandler.getContentContainer().gotoAndPlay("goIn");			
			
			firstClick = false;
			
			trace(firstClick);
		};
		
		
		
		target.onRollOut = function():Void{ this.gotoAndStop(1); };
		target.onRollOver = function():Void{ this.gotoAndStop(2); };
		
		target.onRelease = function():Void{
			
			if(firstClick){
				ComponentHandler.getContentIncluder()._visible = false;	
				
				myLoader.loadClip(url, ComponentHandler.getContentIncluder());	
				firstClick = false;	
				
			}else{
				
				firstClick = true;
				ComponentHandler.getContentContainer().gotoAndPlay("goOut");
				
			}	
			
		};		
		
	}
	
}